﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;

namespace YJKRevitBeam.SplitBream
{
	[Transaction(TransactionMode.Manual)]
	internal class CmdSpiltBream : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			Result result;
			try
			{
				for (;;)
				{
					FamilyInstance selectBream = new SelectBream(commandData).GetSelectBream();
					List<SplitBreamInfo> breamInfo = new NewAnalysisBream(commandData, selectBream).GetBreamInfo();
					if (breamInfo != null && breamInfo.Count > 2)
					{
						new NewInterruptBream(breamInfo, selectBream, commandData).GetNewBreams();
					}
					else
					{
						YJKMessageBox.Show("此梁不是多跨梁", MessageBoxButtons.OK);
					}
				}
			}
			catch
			{
				result = Autodesk.Revit.UI.Result.Succeeded;
			}
			return result;
		}
	}
}
